package Text_86;

import java.lang.reflect.Constructor;

public class Code {

	public static void main(String[] args) throws NoSuchMethodException, SecurityException, ClassNotFoundException {
		//获取字节码文件
        //方式一
        Class aClass = Class.forName("day11.Student");
        //方式二
        Class studentClass = Student.class;
        //方式三
        Student st = new Student();
        Class aClass1 = st.getClass();
        System.out.println(aClass);
        System.out.println(studentClass);
        System.out.println(aClass1);
        //Class类中获取构造方法
        //只能获取公共方法
        Constructor[] con = aClass.getConstructors();
        for (Constructor constructor : con) {
            System.out.println(constructor);
        }
        //获取所有方法
        Constructor[] dec = aClass.getDeclaredConstructors();
        for (Constructor d : dec) {
            System.out.println(dec);
        }
        //获取单个方法
        Constructor dec1 = aClass.getDeclaredConstructor();
        System.out.println(dec1);
        Constructor dec2 = aClass.getDeclaredConstructor(String.class, int.class);
        System.out.println(dec2);


	}

}
